
#ifndef __SHELL_IO_H__
#define __SHELL_IO_H__

#include "stm32f10x_lib.h"
#include  <ucos_ii.h>
#include "CQueue.h"	

#define MAX_LINE_SIZE  128
#define SHELL_BUF_SIZE 128
#define IO_BUF_SIZE    512

typedef struct 
{
	void *dev_handler;
    void (*enable_tx_func)(void *obj, u8 flag);
	u32 txlen;
	Queue rx_queue;
	Queue tx_queue;
	OS_EVENT *rx_mbox;
	OS_EVENT *tx_mbox;
	OS_EVENT *io_mut;
	char rx_queue_buf[SHELL_BUF_SIZE];
	char tx_queue_buf[SHELL_BUF_SIZE];
	char io_buf[IO_BUF_SIZE];
    char cmdline[MAX_LINE_SIZE];		 			
}ShellObj;       

char shell_io_getchar(ShellObj *usartobj, u16 timeout);
u32 shell_printf(ShellObj *usartobj, const char *fmt, ...);
void shell_puts(ShellObj *usartobj, const char *str);
u32 shell_io_gets(ShellObj *usartobj, char *str, u32 len, u16 timeout);
u32 shell_io_getbuf(ShellObj *usartobj, char *bufin, u32 buflen, u32 timeout, s32 retrycnt);
void shell_putchar(ShellObj *usartobj, char c);
char shell_io_puts(ShellObj *usartobj, const char *str, u32 len);
q_int QueueThrowBuf(Queue *queue, q_int n);

#endif

